import "./App.css";
import { invoke } from '@tauri-apps/api/core';
import { readTextFile } from '@tauri-apps/plugin-fs';
import { Routes, Route, HashRouter } from 'react-router-dom';
import Login from './views/login';
import Register from './views/register';
import VariableGenerate from './views/variableGenerate';

async function readFileContent() {
	try {
		const langDe = JSON.parse(await readTextFile('E:\\01_前端基础\\21_Tauri\\tauri-latest-stables\\src\\lang\\de.json'));
		console.log(langDe)
	} catch(e) {
		console.log('该函数只用于 windows => ', e)
	}
}

function useRustFn() {
	try {
		// 处理 Rust 命令函数
		invoke('login_api', { account: 'huan', password: '123456' })
		.then((message) => console.log(message))
		.catch((error) => console.error(error));
	} catch(e) {
		console.log('该函数只用于 windows => ', e)
	}
}

function App() {
	readFileContent()
	useRustFn()
	
	return (
		<HashRouter>
			<Routes>
				<Route path="/login" element={<Login />} />
				<Route path="/register" element={<Register />} />
				<Route path="/" element={<VariableGenerate />} />
			</Routes>
		</HashRouter>
	);
}

export default App;
